<!-- 输出到页面中 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原型对象的应用</title>
</head>
<body>
    <script>
       // 步骤a: 创建一个构造函数Clothes0
function Clothes0() {}

// 步骤b: 基于Clothes0新增2个对象clothes1、clothes2
var clothes1 = new Clothes0();
var clothes2 = new Clothes0();

// 步骤c: 使用prototype给构造函数添加type属性
Clothes0.prototype.type = "衣服";

// 步骤d: 使用prototype属性，给构造函数Clothes0添加ClothesFun方法
Clothes0.prototype.ClothesFun = function() {
    return "这件" + this.type + "是" + this.color + "的" + this.style;
};

// 给clothes1和clothes2添加属性
clothes1.color = "黑色";
clothes1.style = "连衣裙";

clothes2.color = "黄色";
clothes2.style = "吊带裙";

// 步骤e: 在页面中输出结果
console.log(clothes1.ClothesFun()); // 输出：这件衣服是黑色的连衣裙
console.log(clothes2.ClothesFun()); // 输出：这件衣服是黄色的吊带裙

    </script>
</body>
</html>
